package com.huitone.smspfm.context.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**   
* @Title: AppCustomBlockingThreadPool.java 
* @Package com.huitone.smspfm.app.thread 
* @Description: TODO(用一句话描述该文件做什么) 
* @author ybliang   
* @date 2017年3月16日 上午1:30:43 
* @version V1.0   
*/
public class AppCustomBlockingThreadPool {

	/**
	 * 创建一个固定大小并且阻塞的线程池
	 * @param poolSize
	 * @return
	 */
	public static ExecutorService newBlockingThreadPool(int poolSize) {
		return new ThreadPoolExecutor(0, poolSize, 
				60L, TimeUnit.MILLISECONDS, 
				new ArrayBlockingQueue<>(poolSize), 
				new ThreadPoolExecutor.CallerRunsPolicy());
	}
	
	/**
	 * 创建一个固定大小并且阻塞的线程池
	 * @param poolSize
	 * @return
	 */
	public static ExecutorService newBlockingThreadPool2(int poolSize) {
		return new ThreadPoolExecutor(0, poolSize, 
				60L, TimeUnit.MILLISECONDS, 
				new ArrayBlockingQueue<>(poolSize * 10));
	}
	
	private AppCustomBlockingThreadPool(){}
	
}
